package edu.ahpu.propertymanage.util;

import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.FileOutputStream;

@Component
public class WriterExcel {

    static String  ftpPath="G:\\FileHistory\\";

    public Boolean writerExcel(String fileName, SXSSFWorkbook workbook){
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(new File(ftpPath + fileName));
            workbook.write(fileOutputStream);
            //强制将缓存区的数据进行输出
            fileOutputStream.flush();
            //关闭文件流
            fileOutputStream.close();
        } catch (Exception e) {
           return false;
        }
        return true;

    }
}
